import { log } from '../aop/log';
import { AgentInfo, AgentStatus, CheckedGroup, GroupList, GroupSkill, LoginForm, Ring, Scene, Urls, User } from '../interface';
import WidgetConfigure from '../config/WidgetConfigure';

export type InviteMode = 'invite' | 'transfer';
export type ScreenShareStatus = 'idle' | 'start' | 'connected' | 'end';
export type CommandModalType = '';

class StoreDao {
	private static agentInfo: AgentInfo;
	private static ringData: Ring;
	private static agentStatus: AgentStatus;
	private static checkedGroups: CheckedGroup[];
	private static loginForm: LoginForm;
	private static allUserDevices: MediaDeviceInfo[] = [];
	private static allScenes: Scene[] = [];
	private static groupSkill: GroupSkill[] = [];
	private static menuModalVisiable: boolean = false;
	private static menuModalTitle: string = '';
	private static inviteMode: InviteMode = 'invite';
	private static showSendCommand: boolean = false;
	private static screenShareStatus: ScreenShareStatus = 'idle';
	private static showVariableView: boolean = false;
	private static showCustomerRoleOrName: boolean = false;
	private static sendCommandModalType: CommandModalType = '';
	private static inviteAgentIsRobot: boolean = false;
	private static sessionID: string = '';
	private static user: User | null = null;
	private static urls: Urls;
	private static token: string;
	private static rtmpServer: string;
	private static groupList: GroupList[];
	private static agentName: string;
	private static agentID: string;
	private static ticket: string;
	private static transferHeaderOptions = WidgetConfigure.transferHeaderOptions;
	private static profiles: any;
	private static humanflowSteps: any;
	private static sessionSummaryList: any;
	private static unfinishedSummary: number = 0;

	@log('日志消息')
	public static setAgentInfo(agentInfo: AgentInfo) {
		this.agentInfo = { ...this.agentInfo, ...agentInfo };
		return this.agentInfo;
	}

	@log('日志消息')
	public static getAgentInfo() {
		return this.agentInfo;
	}

	@log('日志消息')
	public static setRingData(ringData: Ring) {
		this.ringData = ringData;
	}

	@log('日志消息')
	public static getRingData() {
		return this.ringData;
	}

	@log('日志消息')
	public static setAgentStatus(agentStatus: AgentStatus) {
		this.agentStatus = agentStatus;
	}

	@log('日志消息')
	public static getAgentStatus() {
		return this.agentStatus;
	}

	@log('日志消息')
	public static setCheckedGroups(checkedGroups: CheckedGroup[]) {
		this.checkedGroups = checkedGroups;
	}

	@log('日志消息')
	public static getCheckedGroups() {
		return this.checkedGroups;
	}

	@log('日志消息')
	public static setLoginForm(loginForm: LoginForm) {
		this.loginForm = loginForm;
		return this.loginForm;
	}

	@log('日志消息')
	public static getLoginForm() {
		return this.loginForm;
	}

	@log('日志消息')
	public static setUserDevices(allUserDevices: MediaDeviceInfo[]) {
		this.allUserDevices = allUserDevices;
	}

	@log('日志消息')
	public static getUserDevices() {
		return this.allUserDevices;
	}

	@log('日志消息')
	public static removeDeviceWithID(id: string) {
		this.allUserDevices = this.allUserDevices.filter(device => device.deviceId !== id);
	}

	@log('日志消息')
	public static addDevice(mediaDeviceInfo: MediaDeviceInfo) {
		if (!this.findDeviceWithID(mediaDeviceInfo.deviceId)) {
			this.allUserDevices = [...this.allUserDevices, mediaDeviceInfo];
		}
	}

	@log('日志消息')
	public static findDeviceWithID(id: string) {
		return this.allUserDevices.findIndex(device => device.deviceId === id) !== -1;
	}

	@log('日志消息')
	public static setAllScenes(scenes: Scene[]) {
		this.allScenes = scenes;
		return this.allScenes;
	}

	@log('日志消息')
	public static getAllScenes() {
		return this.allScenes;
	}

	@log('日志消息')
	public static setAllGroupSkill(groupSkill: GroupSkill[]) {
		this.groupSkill = groupSkill;
		return this.groupSkill;
	}

	@log('日志消息')
	public static getAllGroupSkill() {
		return this.groupSkill;
	}

	@log('日志消息')
	public static setMenuModalVisiable(visiable: boolean) {
		this.menuModalVisiable = visiable;
		return this.menuModalVisiable;
	}

	@log('日志消息')
	public static getMenuModalVisiable() {
		return this.menuModalVisiable;
	}

	@log('日志消息')
	public static setMenuModalTitle(title: string) {
		this.menuModalTitle = title;
		return this.menuModalTitle;
	}

	@log('日志消息')
	public static getMenuModalTitle() {
		return this.menuModalTitle;
	}

	@log('日志消息')
	public static setInviteMode(mode: InviteMode) {
		this.inviteMode = mode;
		return this.inviteMode;
	}

	@log('日志消息')
	public static getInviteMode() {
		return this.inviteMode;
	}

	@log('日志消息')
	public static setShowSendCommand(visiable: boolean) {
		this.showSendCommand = visiable;
		return this.showSendCommand;
	}

	@log('日志消息')
	public static getShowSendCommand() {
		return this.showSendCommand;
	}

	@log('日志消息')
	public static setScreenShareStatus(status: ScreenShareStatus) {
		this.screenShareStatus = status;
		return this.screenShareStatus;
	}

	@log('日志消息')
	public static getScreenShareStatus() {
		return this.screenShareStatus;
	}

	@log('日志消息')
	public static setShowVariableView(visiable: boolean) {
		this.showVariableView = visiable;
		return this.showVariableView;
	}

	@log('日志消息')
	public static getShowVariableView() {
		return this.showVariableView;
	}

	@log('日志消息')
	public static setSendCommandModalType(commandModalType: CommandModalType) {
		this.sendCommandModalType = commandModalType;
		return this.sendCommandModalType;
	}

	@log('日志消息')
	public static getSendCommandModalType() {
		return this.sendCommandModalType;
	}

	@log('日志消息')
	public static setShowCustomerRoleOrName(visiable: boolean) {
		this.showCustomerRoleOrName = visiable;
		return this.showCustomerRoleOrName;
	}

	@log('日志消息')
	public static getShowCustomerRoleOrName() {
		return this.sendCommandModalType;
	}

	@log('日志消息')
	public static setInviteAgentIsRobot(inviteAgentIsRobot: boolean) {
		this.inviteAgentIsRobot = inviteAgentIsRobot;
		return this.inviteAgentIsRobot;
	}

	@log('日志消息')
	public static getInviteAgentIsRobot() {
		return this.inviteAgentIsRobot;
	}

	@log('日志消息')
	public static setSessionID(sessionID: string) {
		this.sessionID = sessionID;
		return this.sessionID;
	}

	@log('日志消息')
	public static getSessionID() {
		return this.sessionID;
	}

	@log('日志消息')
	public static setUser(user: User) {
		this.user = user;
		return this.user;
	}

	@log('日志消息')
	public static getUser() {
		return this.user;
	}

	@log('日志消息')
	public static setUrls(urls: Urls) {
		this.urls = urls;
		return this.urls;
	}

	@log('日志消息')
	public static getUrls() {
		return this.urls;
	}

	@log('日志消息')
	public static setToken(token: string) {
		this.token = token;
		return this.token;
	}

	@log('日志消息')
	public static getToken() {
		return this.token;
	}

	@log('日志消息')
	public static setRtmpServer(rtmpServer: string) {
		this.rtmpServer = rtmpServer;
		return this.rtmpServer;
	}

	@log('日志消息')
	public static getRtmpServer() {
		return this.rtmpServer;
	}

	@log('日志消息')
	public static setGroupList(groupList: GroupList[]) {
		this.groupList = groupList;
		return this.groupList;
	}

	@log('日志消息')
	public static getGroupList() {
		return this.groupList;
	}

	@log('日志消息')
	public static setAgentName(name: string) {
		this.agentName = name;
		return this.agentName;
	}

	@log('日志消息')
	public static getAgentName() {
		return this.agentName;
	}

	@log('日志消息')
	public static setAgentID(id: string) {
		this.agentID = id;
		return this.agentID;
	}

	@log('日志消息')
	public static getAgentID() {
		return this.agentID;
	}

	@log('日志消息')
	public static setTicket(ticket: string) {
		this.ticket = ticket;
		return this.ticket;
	}

	@log('日志消息')
	public static getTicket() {
		return this.ticket;
	}
	@log('日志消息')
	public static getTransferHeaderOptions() {
		return this.transferHeaderOptions;
	}

	@log('日志消息')
	public static setProfiles(profiles: any) {
		this.profiles = profiles || {};
	}

	@log('日志消息')
	public static getProfiles() {
		return this.profiles;
	}

	@log('日志消息')
	public static setHumanflowSteps(humanflowSteps: any) {
		this.humanflowSteps = humanflowSteps;
	}

	@log('日志消息')
	public static getHumanflowSteps() {
		return this.humanflowSteps;
	}

	@log('日志消息')
	public static setSessionSummaryList(sessionSummaryList: any) {
		this.sessionSummaryList = sessionSummaryList;
	}

	@log('日志消息')
	public static getSessionSummaryList() {
		return this.sessionSummaryList;
	}

}

export default StoreDao;
